package com.qcby.config;

import com.qcby.handler.AIHandler;
import com.qcby.handler.ChatHandler;
import com.qcby.interceptor.AIInterceptor;
import com.qcby.interceptor.ChatInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@EnableWebSocket
@Component
public class WebSocoketConfig implements WebSocketConfigurer {
    @Autowired
    private ChatHandler chatHandler;
    @Autowired
    private AIHandler aiHandler;
    @Autowired
    private AIInterceptor aiInterceptor;
    @Autowired
    private ChatInterceptor chatInterceptor;
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        //添加一个处理器还有定义处理器的处理路径
        registry.addHandler(chatHandler, "/ws").addInterceptors(chatInterceptor);
        registry.addHandler(aiHandler, "/ai").addInterceptors(aiInterceptor);
    }
}
